import re

def validate_id(id):
    if len(id) > 8:
        return False
    for ch in id:
        if not ch.isdigit() and not ch.isalpha() and ch != '_':
            return False
    return True

def validate_emall(emall):
    if '@' not in emall:
        return False
    parts = emall.split('@')
    if len(parts) != 2:
        return False
    if '.' not in parts[1]:
        return False
    return True

def validate_id_card(id_card):
    if len(id_card) != 18:
        return False
    if not id_card[:17].isdigit():
        return False
    if not (id_card[-1].isdigit() or id_card[-1] == 'X'):
        return False
    return True

def validate_name(name):
    if len(name) > 4:
        return False
    for ch in name:
        if not ('\u4e00' <= ch <= '\u9fff'):
            return False
    return True

def main():
    while True:
        id = input("请输入ID: ")
        if not validate_id(id):
            print("ID格式不正确")
            continue
        else:
            break
    while True:
        emall = input("请输入emall地址: ")
        if not validate_emall(emall):
            print("emall地址格式不正确")
            continue
        else:
            break
    while True:
        id_card = input("请输入身份证号: ")
        if not validate_id_card(id_card):
            print("身份证号格式不正确")
            continue
        else:
            break
    while True:
        name = input("请输入姓名: ")
        if not validate_name(name):
            print("姓名格式不正确")
            continue
        else:
            break

    # 所有输入都符合要求，输出结果
    print(f"注册成功！\nID: {id}\nemall地址: {emall}\n身份证号: {id_card}\n姓名: {name}")


if __name__ == '__main__':
    main()


    
               
        





    